package vsvm.data.filter;

import java.io.Serializable;
import java.util.ArrayList;

import vsvm.data.filter.ranking.EntropyMeasure;
import vsvm.data.filter.ranking.FisherScore;
import vsvm.data.filter.ranking.LaplacianScore;
import vsvm.data.filter.ranking.Soap;
import vsvm.data.filter.ranking.rankingStuff.Normalization;
import vsvm.data.filter.ranking.rankingStuff.SaveSelected;
import vsvm.data.filter.ranking.rankingStuff.SelectSaved;
import vsvm.data.filter.ranking.rankingStuff.Threshold;
import vsvm.data.model.AbstractAttribute;
import vsvm.data.model.AbstractDataModel;

public abstract class AbstractAttributeFilter extends AbstractFilter implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 100L;
	protected ArrayList<AbstractAttribute> attributes;
	
	protected SelectSaved select;
	protected SaveSelected save;
	protected Normalization normalization;
	protected Threshold thresh;
	
	protected LaplacianScore laplacianScore;
	protected EntropyMeasure entropyMeasure;
	protected FisherScore fisherScore;
	protected Soap soap;
	
	protected void initializeStuff()
	{
		save = new SaveSelected();
		select = new SelectSaved(save);
		thresh = new Threshold();
		normalization = new Normalization();
	}
	
	protected void initializeFilters()
	{
		laplacianScore = new LaplacianScore();
		entropyMeasure = new EntropyMeasure();
		fisherScore = new FisherScore();
		soap = new Soap();
	}
	
	public Normalization getNormalization() {
		return normalization;
	}

	public void setNormalization(Normalization normalization) {
		this.normalization = normalization;
	}
	
	public LaplacianScore getLaplacianScore() {
		return laplacianScore;
	}

	public void setLaplacianScore(LaplacianScore laplacianScore) {
		this.laplacianScore = laplacianScore;
	}

	public EntropyMeasure getEntropyMeasure() {
		return entropyMeasure;
	}

	public void setEntropyMeasure(EntropyMeasure entropyMeasure) {
		this.entropyMeasure = entropyMeasure;
	}

	public FisherScore getFisherScore() {
		return fisherScore;
	}

	public void setFisherScore(FisherScore fisherScore) {
		this.fisherScore = fisherScore;
	}

	public Soap getSoap() {
		return soap;
	}

	public void setSoap(Soap soap) {
		this.soap = soap;
	}

	public void setAttributes(ArrayList<AbstractAttribute> attr) {
		attributes = attr;
	}

	protected abstract double transform(double val);
	
	protected void filterDataModel(AbstractDataModel dm, AbstractAttribute attr) {
			int ix = dm.getAtttributeIndex(attr);
			if (ix < 0) return;
			
			for (int j = 0; j < dm.getVectorCount(); ++j)
				dm.setValue(transform(dm.getValue(j, ix)), j, ix);
	}

	public SaveSelected getSave() {
		return save;
	}

	public SelectSaved getSelect() {
		return select;
	}

	public Threshold getThresh() {
		return thresh;
	}
}
